<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<link href="themes/css/ui.common.css" rel="stylesheet"
			type="text/css" />
		<link href="themes/css/ui.child.css" rel="stylesheet"
			type="text/css" />
		<link href="themes/css/ui.tips.css" rel="stylesheet"
			type="text/css" />
		<link href="style/jquery_ui/jquery-ui-1.8.custom.css"
			rel="stylesheet" type="text/css" />
		<link id="skin_css" rel="stylesheet" type="text/css"
			href="themes/css/ui.c.blue.css"></link>
		<link rel="stylesheet"
			href="themes/default/pagination.css" type="text/css"></link>
		<link href="themes/css/ui.selector.css" rel="stylesheet" type="text/css" />
		<script src="Scripts/jquery-1.4.1.min.js"
			type="text/javascript"></script>
		<script type="text/javascript"
			src="Scripts/jquery.json-2.2.min.js"></script>
		<script src="Scripts/jquery-ui-1.8.custom.min.js"
			type="text/javascript"></script>
		<script src="Scripts/ui.tips.js" type="text/javascript"></script>
    	<script src="Scripts/ui.default.js " type="text/javascript" charset="UTF-8"></script>
		<script src="Scripts/ui.admincp.js"
			type="text/javascript" charset="UTF-8"></script>
		<script src="Scripts/ui.objectSelector.js" type="text/javascript"></script> 
		<script type="text/javascript"
			src="Scripts/ui.dialogFormHelper.js"></script>
		<script type="text/javascript" src="Scripts/ui.clientDateHelper.js"></script>
		<STYLE type="text/css">
.editorArea {
	display: none;
}
tr{margin-bottom:10px;}
</STYLE>
		<script type="text/javascript">
				$(function()
				{
					$("#dialog-form-view").dialog({
					autoOpen: false,
					height: 300,
					width: 460,
					modal: true,
					buttons: {
					Cancel: function() {
					$(this).dialog('close');
					}
					},
					close: function() {
					}
					});
			
					$("#dialog").dialog("destroy"); 
					$("#dialog-form").dialog({
					autoOpen: false,
					height: 550,
					width: 760,
					modal: true, 
					close: function() {
				}
			});
			
				$('#addAssessModelButton').click(function() {  
			    $('#dialog-form').dialog('open'); 	
				});
			
				$("#itemSelectorArea").objectSelector({
                fromAjax: true,
                ajaxDataAction: "assessModel!getItemsByCategoryId.action",
                subGroupBuilder: subGroupBuilder,
                postArgBuilder :function(entityId){ return {categoryId: entityId};}
				});
			    
		    	});
		    	function subGroupBuilder(item) 
		    	{
            		var categoryId = item.itemCategory.categoryId;
            		var itemName = item.itemName;
            		var itemId = item.itemId;
            		var groupId = categoryId;
            		return '<div class="groupItem"><a class="lm_addr" key="g' + categoryId + '" href="javascript:void(0)"><input type="button" class="move" />'
            		+ '<div class="arguementBar" key="g' + categoryId  + '" entityId="' + itemId + '" itemindex="0" title="">'
            		+ itemName + ' <span class="details Tips3"></span></div></a></div>';
       			 }
        
		
				function doDialogSubmit()
				{
		    		var assessModelName = $("#dialog-assessModel-name").val();
		 			var itemSelected =  "";
		    		$("#itemSelectorArea").find(".rightContainer:first").find(".arguementBar").each(function(item){
		        	itemSelected+= $(this).attr("entityId")+"," ;
		         	});   
		    		var _result = { 
		        	assessModelName:assessModelName,
		        	itemIds:itemSelected
		    		};
		    		var result=$.toJSON(_result); 
		    		$.post("assessModel!addModel.action",{result:result},function(e){location="assessModel!manager.action?add=1";		 
		    		},"json");
				}
			
				var searching = false;
				$(function(){
					$("#link_page_prev,#link_page_next").click(function(){
			    		var currentPage = $(this).attr("currentPage");
			    		goToPage(currentPage);
			    	}); 
			    	$("#searchButton").click(function(){
						searching=true;
			    		goToPage(1);
			    	});
			    	initSearch();
			    	registeRowFuncButton();
				});
				
				function initSearch()
				{
				    $("#txt_noticeTitle").val();
				}
			 
				function goToPage(currentPage)
				{
				    var modelName =$("#txt_modelName").val();  
					location.href = "assessModel!manager.action?currpage="+currentPage+"&modelName="+modelName;
				}  

	        	function toShowDetailHandler(e) 
	        	{  
					var columns = e.data;
					var modelId = e.entityId;
					$.post("assessModel!queryDetail.action?modelId="+modelId,null,function(data){
					var jsonClientObject = eval(data);
					var assessItemList = jsonClientObject.assessItemList;	
				 	var result = foreachHandler(assessItemList,function(item){ 	
				  	return '<tr><td>'+item.itemName+'</td><td>'
				  	+item.itemCategory.categoryName+'</td><td>'+item.highScore+'</td></tr>';
				 	});
			     	$("#assessItemInfoContainer").html(result);
			     	$('#dialog-form-view').dialog('open');
					},"json");
				}
				
				function checkAll(str)
				{
　 					var items = document.getElementsByName(str);　 //获取所有复选框
　					var totalNum = items.length;　 //获取复选框的个数
　 					for (var i=0; i<totalNum; i++)
　 					items[i].checked = window.event.srcElement.checked;//通过单击的按钮判断是选中还是未选
				}
				
				function deleteAll(str)
				{
					var isTo = checkDeleteAll("模版信息");
					if(isTo==false)
  					return ;
　 					var items = document.getElementsByName(str);　 //获取所有复选框
　					var totalNum = items.length;　 //获取复选框的个数
					var delStr = "";
　 					for (var i=0; i<totalNum; i++){
　 						if(items[i].checked == true){
							delStr += items[i].value + ","; 
						}
					}
					delStr = delStr.substring(0, delStr.length -1);
					location.href= "assessModel!deleteMoreAssessModel.action?modelIds="+delStr+"&currpage="+${currpage};
				}
				
				
			</SCRIPT></head>

	<body>
	 <div class="PageChild_Title">
        <img src=" themes/images/default/icons/archives.png" class="PageChild_Tbtnpic" />
        <span class="PageChild_separate"></span><span class="PageChild_TbtnText">
        <h2>
        	管理考核模版
        </h2>
        </span><span class="PageChild_separate"></span>
        <div id="marker" class="red-tips">
        </div>
        <div class="clear">
        </div>
    </div>
		<div class="PageChild_Where">
			<table style="height:60px" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td class="mtd">
						&nbsp;模版名称:<s:textfield name="modelName" maxlength="20"
							id="txt_modelName" theme="simple" />
					</td>
					<td>
					<input type="submit" name="searchButton" class="o-btn SubmitButton" value="搜索"
							id="searchButton" />
					</td>
				</tr>
				<tr>
					<td>
						&nbsp;<input type="button" id="addAssessModelButton" class="o-btn" value="添加"/>
					</td>
				</tr>
				<tr>
					<td colspan="5">	
						&nbsp;<span id="lbl_list_count">共搜索到 <b>${count}</b> 条模版信息。</span>
					</td>
				</tr>
			</table>
		</div>
		<div class="PageChild_List">
			<table width="100%" border="0" cellspacing="0"
				style="text-align: left">
				<tbody class="PageChild_List_head">
					<tr>
						<td width="16">
							<input id="Chk_All" type="checkbox" name="Chk_All"
								onclick="checkAll('Chk_Num')" />
						</td>
						<td>
							模版名称
						</td>
						<td class="td_width40" >
							详情
						</td>
						<td class="td_width40">
							删除
						</td>
						<td class="td_width40">
							状态
						</td>
					</tr>
				</tbody>
				<tbody class="PageChild_List_main" style="text-align: left">
					<!-- 模版列表开始 -->
					<s:if test="list!=null&&list.size!=0">
					<s:iterator value="list" var="item">
						<tr class='td_no_bord'>
							<td class="td_width25">
							<span title="${item.modelId}"><input id="Chk_Num" type="checkbox"
										name="ReptShow$ctl01$Chk_Num" value="${item.modelId}" /> </span>
							</td>
							<td>
								<span>${item.modelName}&nbsp;</span>
							</td>	
							<td>
								<a class="ui-link-viewDetail-button"
									entityId="${item.modelId}" id="sender_${item.modelId}"
									href="javascript:void(0);" state="0"
									entityId="${item.modelId}"> <img
										src="themes/icons/info.png" title="单击查看模版详细信息" />
								</a> 
							</td>
							<td>
							<a href="javascript:;"
									onclick='location="assessModel!deleteAssessModel.action?modelId=${item.modelId}&currpage=${currpage}";'><img
										src="themes/icons/delete.png" title="单击删除模版信息"/> 
								</a>
								</td>
							<td>
							<s:if test="#item.states==1">
							<a href="javascript:;"
									onclick='location="assessModel!toDisableAssessModel.action?modelId=${item.modelId}&currpage=${currpage}"'><img
										src="themes/icons/btn_enable.png" title="当前状态为可用"/> </a>
							</s:if>
							<s:if test="#item.states==0">
							<a href="javascript:;"
									onclick='location="assessModel!toEnableAssessModel.action?modelId=${item.modelId}&currpage=${currpage}"'><img 
									src="themes/icons/btn_disable.png" title="当前状态为不可用" /> </a>
							</s:if>	
							</td>
						</tr>
					</s:iterator>
					</s:if><s:else>
					<tr>
						<td colspan="5"></td>
					</tr>
					</s:else>
					<!-- 模版列表结束 -->

				</tbody>
			</table>
			<div id="divTopPageNavi" class="list_r_title_text3">

				<!--分页导航开始-->
				<s:if test="currpage<=1">
					<span class='list_r_title_text3a'> <img
							src="<%=basePath%>/themes/images/default/page_up_gray.gif"></img>
					</span>

				</s:if>
				<s:else>
					<span class='list_r_title_text3a'> <a name="link_page_prev"
						id="link_page_prev" href="javascript:void(0);"
						currentPage="${currpage-1}"> <img
								src="<%=basePath%>/themes/images/default/page_up.gif"></img> </a> </span>
				</s:else>
				<span class='list_r_title_text3b'> 第${currpage
					}页/共${totalpage }页 </span>
				<s:if test="currpage>=totalpage">
					<span class='list_r_title_text3a'> <img
							src="<%=basePath%>/themes/images/default/page_down_gray.gif"></img>
					</span>
				</s:if>
				<s:else>
					<span class='list_r_title_text3a'> <a name="link_page_next"
						id="link_page_next" href="javascript:void(0);"
						currentPage="${currpage+1 }"> <img
								src="<%=basePath%>/themes/images/default/page_down.gif"></img> </a>
					</span>
				</s:else>
				<span id="goToPageTextArea"><input type="text"
						class="easyui-numberbox" id="goPageNum" max="${totalpage}" min="1" />
					<input type="button" id="turnToPageButton" value="GO" />
				</span>
				<!--分页导航结束-->
			</div>
			<div>
			<input type="button" name="btn_Delete" class="o-btn SubmitButton"
				value="删 除" id="btn_Delete"
				onclick="deleteAll('ReptShow$ctl01$Chk_Num')">
			</div>
		</div>

		<div id="dialog-form-view" title="考核模版详情" style="padding: 10px;">
		<table width="100%" border="0" cellspacing="0"
				style="text-align: left">
				<tbody class="PageChild_List_head">
					<tr>
						<td>
							考核项目名称
						</td>
						<td>
							考核项目类型
						</td>
						<td>
							项目最高分
						</td>
					</tr>
				</tbody>
				<tbody id="assessItemInfoContainer" class="PageChild_List_main" style="text-align: left">
					<!-- 会议通知列表开始 -->
					
					<!-- 会议通知列表结束 -->

				</tbody>
			</table>
		</div>
	
		<div id="dialog-form" title="添加考核模版" style="padding: 10px;">
		<table width="100%" border="0" cellspacing="0">
		<tr>
			<td class="mtd" width="100px;" style="height:26px">考核模板名称:</td> 
				<td>
				<input type="text" value="" class="input-control" style="width:200px;" id="dialog-assessModel-name"/>
				</td>
		</tr>
<tr>

<td class="mtd" width="100px;" style="height:26px">
	考核项目:
</td>
<td>
	 <div id="itemSelectorArea" selectorresult="#txt_PeopleReceiver" style="">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td valign="top">
                        <span>考核项目列表:</span>
                        <div class="Box leftContainer" style="overflow-y: auto; height: 302px;">
                            <div class="lm_sbar hiddenObject">
                                <input type="button" class="lm_sopen" style="" />
                                <div>
                                    <input type="text" style="height: 19px;" value="查找项目..." class="txt" />
                                </div>
                            </div>
                            <div style="display: none">
                                查找到以下结果:
                                <div>
                                </div>
                            </div>
                            <div class="lm_panel hiddenObject" style="">
                            </div>
                            <div class="lm_panel" style="height: 100%;">
                                <s:iterator value="categoryList" var="item"> 
                                        <div class="groupclose" key="g${item.categoryId }" entityId="${item.categoryId }" open="false" hasload="false" style="font-weight: bolder;">
                                        <div style="padding: 2px 0pt 1px; background: none repeat scroll 0% 0% rgb(255, 255, 255);
                                            color: black;" onmouseout="this.style.background='#fff'" onmouseover="this.style.background='#ffeec2'"
                                            class="">
                                            <div class="clear"></div>
                                            <span class="Tips3 lm_helper">全部添加</span>
                                            <div class="lm_ca" title="${item.categoryName}">
                                                <input type="button" class="lm_ico" />
                                                ${item.categoryName} <span class="Tips3 groupItemCountTips"  id="groupTips_${item.categoryId }">(未加载)</span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="groupsub" key="g${item.categoryId}">
                                    </div>
                                </s:iterator>
                                
                            </div>
                        </div>
                    </td>
                    <td align="center" style="padding: 5px;">
                        <img alt="" src="style/arrow_left.gif" />
                    </td>
                    <td valign="top">
                        <span>已选择(<span id="count_Receiver" class="receiverCounter">0</span>)</span>
                        <div id="add_address" style="overflow-y: auto; height: 302px; padding-left: 3px;"
                            class="Box objectSelectorContainer rightContainer">
                        </div>
                    </td>
                </tr>
            </table>
</div>
</td>		
</tr>	
		</table>	
		<input type="button" name="name" id="btnSubmit" onclick="return doDialogSubmit();"
                    value="确定"   />
		<input type="button" name="name" id="cancelAddGoodsInfoButton"
										class="dialogFormCloseButton" dialogForm="#dialog-form"
										value="取消" />
		</div>
	</body>

</html>
